package org.apache.struts2.dispatcher;

import com.opensymphony.xwork2.ActionInvocation;
import com.wyzz.hr.base.FileOperate;

import java.io.File;
import org.apache.commons.lang.StringUtils;

public class StreamResultDeleted extends StreamResult {

	public StreamResultDeleted() {
	}

	public void execute(ActionInvocation invocation) throws Exception {
		super.execute(invocation);
		serverFileName = (String) invocation.getStack().findValue(
				"serverFileName", java.lang.String.class);
		if (StringUtils.isNotEmpty(serverFileName)) {
			File serverFile = new File(serverFileName);
			FileOperate.deleteFile(serverFile);
		}
	}

	public String getServerFileName() {
		return serverFileName;
	}

	public void setServerFileName(String serverFileName) {
		this.serverFileName = serverFileName;
	}

	private static final long serialVersionUID = 0x7627b229L;
	protected String serverFileName;
}
